home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc20 / dirent.h < prev    next >
C/C++ Source or Header  |  1992-05-15  |  3KB  |  93 lines

  1. /* header file for POSIX directory access routines */
  2.  
  3. #ifndef _DIRENT_H
  4. #define _DIRENT_H
  5.  
  6. #ifndef _COMPILER_H
  7. #include <compiler.h>
  8. #endif
  9.  
  10. #ifndef _TYPES_H
  11. #include <types.h>
  12. #endif
  13.  
  14. #ifndef NAME_MAX
  15. # include <limits.h>
  16. #endif
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22.  
  23. #ifndef _LIB_NAME_MAX
  24. #  define _LIB_NAME_MAX NAME_MAX
  25. #endif
  26.  
  27. struct dirent {
  28.        long            d_ino;          /* garbage under TOS */
  29.        off_t           d_off;          /* position in directory  */
  30.        short           d_reclen;       /* for us, length of d_name */
  31. #ifndef __MINT__
  32. /* the following (except for d_name) are unique to TOS */
  33.        struct dirent   *d_next;        /* ptr to next struct dirent in list */
  34.        unsigned char   d_attribute;    /* file modes from Fsfirst()  */
  35.        unsigned short  d_time, d_date; /* TOS date and time for file */
  36.        long            d_size;         /* file size */
  37.        char            d_name[1];
  38. #else
  39.        char            d_name[NAME_MAX+1];
  40. #endif
  41. };
  42.  
  43. #ifndef __MINT__
  44. typedef struct _DIR {
  45.        struct dirent *D_list;          /* list of directory entries */
  46.        struct dirent *D_curpos;        /* current position in list  */
  47.        char          *D_path;          /* path to this directory    */
  48.        struct _DIR   *D_nxtdir;        /* next DIR in opendir chain */
  49. } DIR;
  50.  
  51. #else
  52.  
  53. typedef struct _DIR {
  54.     short    status;        /* status of the search so far: */
  55. #define _INSEARCH    0    /* need to call Fsnext for a new entry */
  56. #define _STARTSEARCH    1    /* Fsfirst called once, successfully */
  57. #define _NMFILE        2    /* no more files in directory */
  58.     char    dta[44];    /* TOS DTA for this directory */
  59.     char    *dirname;    /* directory of the search (used under
  60.                    TOS for rewinddir) */
  61.     struct dirent buf;    /* dirent struct for this directory */
  62. } DIR;
  63.  
  64. #endif /* __MINT__ */
  65.  
  66.  
  67. #define DIRENTSIZ(x) (sizeof(struct dirent) + (x) + 1)
  68.  
  69. /* allow BSD emulation via sys/dir.h */
  70.  
  71. #ifdef _SYS_DIR_H
  72. #define direct        dirent
  73. #define d_fileno    d_ino
  74. #define d_namlen    d_reclen
  75.  
  76. #define DIRSIZ(dp)     DIRENTSIZ((dp)->d_namlen)
  77. #define MAXNAMLEN    _LIB_NAME_MAX
  78. #endif
  79.  
  80.  
  81. __EXTERN DIR *        opendir    __PROTO((const char *dirname));
  82. __EXTERN struct dirent *readdir    __PROTO((DIR *dirp));
  83. __EXTERN off_t        telldir __PROTO((DIR *dirp));
  84. __EXTERN void        seekdir    __PROTO((DIR *dirp, off_t loc));
  85. __EXTERN void        rewinddir __PROTO((DIR *dirp));
  86. __EXTERN int        closedir  __PROTO((DIR *dirp));
  87.  
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91.  
  92. #endif /* _DIRENT_H */
  93.